package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Examine;
import com.dragon.repository.entity.ExamineFile;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ExamineVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "流程类型")
    private Integer streamType;

    @ApiModelProperty(value = "关联主表id")
    private Integer correlationId;

    @ApiModelProperty(value = "0，待审核，1审核通过，2审核不通过")
    private Integer status;

    @ApiModelProperty(value = "审核类型：1、依次顺序审核，2、会签（可同时审核），3、或签")
    private Integer auditType;

    @ApiModelProperty(value = "申请人id")
    private Integer applicantId;

    @ApiModelProperty(value = "所有流程执行完都要抄送的人")
    private String toTotalAdmin;

    @ApiModelProperty(value = "抄送是否可编辑，0否，1是")
    private Integer isUpdate;

    @ApiModelProperty(value = "是否有抄送，0否，1是")
    private Integer isSend;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "审批类型 0：表单审核 1：申请修改")
    private Integer examineType;

    @ApiModelProperty(value = "是否允许加签:0不允许，1允许")
    private Integer isAddSign;

    @ApiModelProperty(value = "加签类型: 0，未加签，1，前加签，2、后加签")
    private Integer addSignType;

    @ApiModelProperty(value = "加签的审核人id,方便排序操作")
    private Integer signUserId;

    @ApiModelProperty(value = "加签id集合")
    private String examineAuditUserIds;

    @ApiModelProperty(value = "审核附件数据")
    private List<ExamineFile> examineFiles;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "子表审核意见")
    private String opinion;


    @NotNull(groups = Update.class, message = "主键不能为空")
    public static Examine convert(ExamineVO vo) {
        Examine entity = new Examine();
        BeanUtils.copyProperties(vo, entity);
        return entity;
    }

    public static List<Examine> convertList(List<ExamineVO> list) {
        List<Examine> resultList = new ArrayList<>();
        for (ExamineVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
